<template>
  <div class="swiper-container" :id="swiperId">
    <div class="swiper-wrapper">
      <div  v-bind:key="index" v-for="(item,index) in swiperD" class="swiper-slide swiper-slide-next" @click="slideTo(item.url)">
        <img :src="item.imgHref" />
      </div>
    </div>
    <div class="swiper-pagination"></div>
  </div>
</template>

<script>
import Swiper from 'swiper'

export default {
  props: [ 'swiperId', 'swiperD' ],
  data () {
    return {

    }
  },
  mounted () {
    this.sw()
  },
  methods: {
    sw () {
      let that = this
      // eslint-disable-next-line
      let lunbo = new Swiper('#' + that.swiperId, {
        pagination: '.swiper-pagination',
        paginationClickable: true,
        longSwiperRatios: 0.3,
        setWrapperSize: true,
        autoplay: 3000,
        autoplayDisableOnInteraction: false,
        loop: true
      })
    },
    slideTo (url) {
      console.log(url, window)
      window.location.href = url
    }
  }
}
</script>

<style>
  @import url(./swiper.min.css);
  .swiper-container{
    padding-top:2.45rem;
    min-height:150px;
  }
  .swiper-slide{
    width:100%
  }
  .swiper-slide img{
    width:100%;
    display: block;
  }
</style>
